﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data;
using QLHD.BLL;

namespace QLHD.DAL
{
    public static class NhaCC_DB
    {
        public static DataTable selectNCC()
        {
            using (SqlConnection con = Connection.GetConnection())
            {
                SqlDataAdapter da = new SqlDataAdapter("spSelectNCC", con);
                con.Open();
                SqlCommand cmd = new SqlCommand("spSelectNCC", con);
                cmd.CommandType = CommandType.StoredProcedure;
                DataTable dt = new DataTable();
                da.Fill(dt);
                return dt;
            }

        }
        public static void InsertNCC(NhaCC NCC)
        {
            using (SqlConnection con = Connection.GetConnection())
            {
                SqlDataAdapter da = new SqlDataAdapter("spThemNCC", con);
                con.Open();
                SqlCommand cmd = new SqlCommand("spThemNCC", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@MaNCC", NCC.MANCC);
                cmd.Parameters.AddWithValue("@TenNCC", NCC.TENNCC);
                cmd.Parameters.AddWithValue("@DiaChi", NCC.DIACHI);
                cmd.Parameters.AddWithValue("@DienThoai", NCC.DIENTHOAI);
                cmd.ExecuteNonQuery();
            }
        }
        public static void UpdateNCC(NhaCC NCC)
        {
            using (SqlConnection con = Connection.GetConnection())
            {
                SqlDataAdapter da = new SqlDataAdapter("spCapNhatNCC", con);
                con.Open();
                SqlCommand cmd = new SqlCommand("spCapNhatNCC", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@MaNCC", NCC.MANCC);
                cmd.Parameters.AddWithValue("@TenNCC", NCC.TENNCC);
                cmd.Parameters.AddWithValue("@DiaChi", NCC.DIACHI);
                cmd.Parameters.AddWithValue("@DienThoai", NCC.DIENTHOAI);
                cmd.ExecuteNonQuery();
            }
        }
        public static void DeleteNCC(NhaCC NCC)
        {
            using (SqlConnection con = Connection.GetConnection())
            {
                SqlDataAdapter da = new SqlDataAdapter("spXoaNCC", con);
                con.Open();
                SqlCommand cmd = new SqlCommand("spXoaNCC", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@MaNCC", NCC.MANCC);
                cmd.ExecuteNonQuery();
            }



        }
    }
}
